#include<cstdio>
#include<iostream>

#define LL long long

using namespace std;

void exgcd(LL a,LL b,LL &d,LL &x,LL &y)
{
	if(b==0)
	{
		d=a;
		x=1;
		y=0;
	}
	else
	{
		exgcd(b,a%b,d,x,y);
		LL temp=x;
		x=y;
		y=temp-a/b*y;
	}
}

LL f(LL a,LL b,LL m)
{
	LL d,x,y;
	exgcd(a,m,d,x,y);
	if(b%d)return -1;
	x=x*(b/d);
	while(x<0)x+=m/d;
	x=x%m;
	return x;
}

int main()
{
	LL x,y,m,n,L;
	cin>>x>>y>>m>>n>>L;
	LL ans=f(n-m,x-y,L);
	if(ans==-1)printf("Impossible\n");
	else cout<<ans<<endl;
	return 0;
}
